@extends('layout.page')
@section('title','渠道 - 数据跟踪')
@section('stylesheet')
    <link href="/css/plugins/datepicker/datepicker3.css" rel="stylesheet">
@endsection

@section('static-page')
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>渠道 <small>数据追踪</small></h5>
                </div>
                <div class="ibox-content">
                    @if($channel)
                    <h3>费用总览</h3>
                    <div class="gray-bg col-md-12 m-b-md">
                        <div class="col-md-3 p-m">总成交金额：{{$channel['invest_num']}}</div>
                        <div class="col-md-3 p-m">总成本：{{$channel['real_amount']}}</div>
                        <div class="col-md-3 p-m">年化ROI：{{ratio($channel['invest_num'], $channel['real_amount'])}}</div>
                        <div class="col-md-3 p-m">订单率：{{percent($channel['invest_success_number'], $channel['invest_total_number'])}}</div>
                        <div class="col-md-3 p-m">新增注册：{{$channel['reg_num']}}</div>
                        <div class="col-md-3 p-m">新增实名：{{$channel['real_num']}}</div>
                        <div class="col-md-3 p-m">实名率：{{percent($channel['real_num'], $channel['reg_num'])}}</div>
                        <div class="col-md-3 p-m">复投率：{{percent($channel['invest_success_number'] - $channel['invest_first_number'], $channel['invest_success_number'])}}</div>
                    </div>
                    @endif

                    <div class="form-group">
                        <label class="col-sm-2 control-label">时间：</label>
                        <div class="col-sm-6">
                            <div class="input-daterange input-group" id="datepicker">
                                <input type="text" class="input-sm form-control" readonly id="date-start" value="{{$start_time}}" />
                                <span class="input-group-addon"> —— </span>
                                <input type="text" class="input-sm form-control" readonly id="date-end" value="{{$end_time}}" />
                            </div>
                        </div>
                        <div class="col-sm-4"><a class="btn btn-success" id="btn-time">筛选</a></div>
                    </div>

                    <table class="table table-bordered text-center">
                        <thead class="text-center">
                        <tr>
                            <th>日期</th>
                            <th>注册量(人)</th>
                            <th>实名量(人)</th>
                            <th>首投</th>
                            <th>成交金额</th>
                            <th>60天以内</th>
                            <th>60-150天</th>
                            <th>150-300天</th>
                            <th>300天以上</th>
                            <th>使用现金券</th>
                            <th>发放红包</th>
                            <th>年化ROI比</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($list as $daily)
                            <tr data-date="{{$daily['date']}}">
                                <td>{{substr($daily['date'],0,4)}}年{{substr($daily['date'],4,2)}}月{{substr($daily['date'],6,2)}}日</td>
                                <td><a href="/ceb/channels/registers?date={{$daily['date']}}&is_realname=0&channel_code={{$channel['channel_code']}}">{{$daily['reg_num']}}</a></td>
                                <td><a href="/ceb/channels/registers?date={{$daily['date']}}&is_realname=0&channel_code={{$channel['channel_code']}}">{{$daily['real_num']}}</a></td>
                                <td>
                                    <a href="/ceb/channels/deals?date={{$daily['date']}}&is_first=0&channel_code={{$channel['channel_code']}}">
                                    {{$daily['first_invest']}}
                                    </a>
                                </td>
                                <td>
                                    <a href="/ceb/channels/deals?date={{$daily['date']}}&is_first=0&channel_code={{$channel['channel_code']}}">
                                    {{$daily['deal_total']}}
                                    </a>
                                </td>
                                <td>
                                    <a href="/ceb/channels/deals?date={{$daily['date']}}&is_first=0&channel_code={{$channel['channel_code']}}&duration={{\App\Constants\InvestmentDuration::DAYS_60}}">
                                    {{$daily['days_60']}}
                                    </a>
                                </td>
                                <td>
                                    <a href="/ceb/channels/deals?date={{$daily['date']}}&is_first=0&channel_code={{$channel['channel_code']}}&duration={{\App\Constants\InvestmentDuration::DAYS_150}}">
                                    {{$daily['days_150']}}
                                    </a>
                                </td>
                                <td>
                                    <a href="/ceb/channels/deals?date={{$daily['date']}}&is_first=0&channel_code={{$channel['channel_code']}}&duration={{\App\Constants\InvestmentDuration::DAYS_300}}">
                                        {{$daily['days_300']}}
                                    </a></td>
                                <td>
                                    <a href="/ceb/channels/deals?date={{$daily['date']}}&is_first=0&channel_code={{$channel['channel_code']}}&duration={{\App\Constants\InvestmentDuration::DAYS_OTHERS}}">
                                        {{$daily['days_others']}}
                                    </a>
                                </td>
                                <td>{{$daily['voucher_num']}}</td>
                                <td>{{$daily['gift_num']}}</td>
                                <td>@if($channel) {{ratio($daily['deal_total'],$channel['real_amount'])}} @endif</td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                    @include('wiget.pager',[
                        'page' => $page,
                        'page_size' => $size,
                        'count' => $count,
                        'show_count' => 10,
                        'path' => url('/ceb/channels/daily?channel_id=' . $channel_id . '&start_time=' . $start_time . '&end_time=' . $end_time)
                    ])
                </div>
            </div>
        </div>
        @endsection

@section('javascript')
<script src="/js/plugins/datepicker/bootstrap-datepicker.js"></script>
<script>
    var channel_id = {{$channel_id}};
    $(document).ready(function () {

        setDateRange('#date-start','#date-end');

        $('#btn-time').on('click',function(){
            var start = $('#date-start').val();
            var end = $('#date-end').val();
            go_page('/ceb/channels/daily',{
                start_time:start,
                end_time:end,
                channel_id:channel_id
            });
        });
    });
</script>
@endsection
